﻿<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>东股资金流</title>
    <link href="css/text.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
      /* //p {margin:5px}
      //ul {margin:1px}
      //h4 {margin:1px} */
      .fixedBox {
        border: 1px solid #555555;
        white-space: nowrap;
      }
      .fixedBox::-webkit-scrollbar {
        width: 0px;
        height: 0px;
      }
      a {
        margin: 0;
      }
      div{
        padding-left:0;
        margin-bottom:0;
        
      }

    </style>
    <script type="text/javascript" src="js/json2html.js"></script>
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script>
      var time = 3000; //延迟多久刷新
      var renovate = true;
      window.onhashchange = hashChangeFire;
      function hashChangeFire() {
        location.reload();
      }
      var dict = {
        1: "被动卖",
        2: "主动买",
        3: "被动买",
        4: "主动卖",
      };
      var ft = 1;
      var buy = false;
      gp = window.location.href.split("##");
      var code = gp[1];
      var is688 = code[0] + code[1] + code[2] == "688" ? 1 : 0;
      window.onload = function () {
        changeStyle();
      };

      getSource2();

      var int = setInterval(function () {
        if (renovate) {
          getSource2();
        }
      }, time);

      function getSource2() {
        // var url = "https://puoney.com/getStockFenShi?pagesize=999999&ut=7eea3edcaed734bea9cbfc24409ed989&dpt=wzfscj&pageindex=0&id=3003002&sort=1&ft="+(ft==8?'1':ft)+"&code="+code+"&market="+( code[0]==0||code[0]==3?'0':'1')+"&_=1636782020528"
        var url =
          "https://apphq.longhuvip.com/w1/api/index.php?Order=0&st=20000&a=GetMainMonitor_w30&c=StockYiDongKanPan&PhoneOSNew=1&DeviceID=00000000-296c-20ad-0000-00003eb74e84&VerSion=5.7.0.12&Token=4e7fa8458a2add3f14a50ca79e863772&Index=0&Money=3&apiv=w31&StockID=" +
          code + "&UserID=1973778&IsBS=0&";

        if (window.XMLHttpRequest) {
          xmlHttp1 = new XMLHttpRequest();
        } else {
          xmlHttp1 = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlHttp1.onreadystatechange = writeSource2;
        xmlHttp1.open("GET", url, true);
        xmlHttp1.send(null);
      }

      function writeSource2() {
        if (xmlHttp1.readyState == 4) {
          var data = JSON.parse(xmlHttp1.responseText);
          var len = 0;
          var list = [];
          len = data.List.length;
          switch (ft) {
            case 1:
              list = data.List;
              // for (let i = 0; i < len; i++) {
              //   list = data.List;
              // }
              break;
            case 8:
              for (let i = 0; i < len; i++) {
                if (data.List[i][3] >= 500000) {
                  console.log(data.List[i][3]);
                  //console.log(data.data.data[i].p/1000,data.data.data[i].v*100,(data.data.data[i].t/1000)*(data.data.data[i].v*100));
                  // console.log((data.data.data[i].t/1000)*(data.data.data[i].v*100));
                  list.push(data.List[i]);
                }
              }
              console.log(list);
              break;

            default:
              for (let i = 0; i < len; i++) {
                let j = parseFloat(data.List[i][3]);
                // if (data.List[i][2] >= ft) {
                if (j >= ft * 10000) {
                  list.push(data.List[i]);
                }
              }
              break;
          }

          if (buy) {
            let list2 = [];
            for (let i = 0; i < list.length; i++) {
              let item = list[i];
              if ([2, 3, "2", "3"].includes(item[0])) {
                list2.push(list[i]);
              }
            }
            list = list2;
          }
          list.reverse();
          console.log(list);

          // if(len>=6){
          // 	for(let i=len-6;i<len;i++){
          // 		list.push(data.data.data[i])
          // 	}
          // }else{
          // 	for(let i=0;i<len;i++){
          // 		list.push(data.data.data[i])
          // 	}
          // }

          list = '{"data":' + JSON.stringify(list) + "}";
          // console.log(list);

          var transform_aa = [
            {
              tag: "span",
              children: function () {
                return json2html.transform(this.data, transform_bb);
              },
            },
          ];

          //m = 0;
          var transform_bb = {
            tag: "ul",
            children: [
              {
                tag: "li",
                children: function () {
                  //   console.log(this[0], this[4], this[3]);

                  //m++;
                  return (
                    "<a style='display: flex'>" +
                    this[5].split(" ")[1] +
                    "&nbsp;&nbsp;" +
                    // NumberTransform2(this[2], 1) +
                    // (ft == 8
                    //   ? setColor(this[3], this[0], 1, 1, "万", 10000)
                    //   : setColor(this[2], this[0], 1, 0)) +

                    setColor(this[3], this[0], 1, 1, "万", 10000) +
                    "&nbsp;&nbsp;" +
                    setColor(this[2], this[0],1,0,"手",1)+
                    "&nbsp;&nbsp;" +
                    setColor(this[4], this[0]) +
                    // (ft != 8 ? this[3] : (this[4] / 10000).toFixed(2) + "万")
                    "&nbsp;" +
                    setColor(this[0], this[0], 0) +
                    "</a>"
                  );
                },
              },
            ],
          };

          var html = json2html.transform(list, transform_aa);
          div = document.getElementById("towrite2");
          div.innerHTML = "";
          div.innerHTML = div.innerHTML + "<span id='gg'>" + html + "</span>";
          div.scrollTop = div.scrollHeight;
          let cishu = $("#gg span").children().length;
          $("#towrite3").html("");
          return;
          //高亮
          var content = document.getElementById("gg").innerHTML;
          var reg = new RegExp("( " + gl + ")", "g");
          var str = content;
          var newstr = str.replace(reg, "<font color=#FF6633>$1</font>");
          document.getElementById("gg").innerHTML = newstr;
        }
      }

      function setJr(n, type, i = 1, t = 2) {
        if (["1", "4"].includes(type)) {
          return (
            '<span style="color:#00FF00;flex: 1;">' +
            parseFloat(n).toFixed(t) +
            "</span>"
          );
        } else {
          return (
            '<span style="color:red;flex: 1;">' +
            parseFloat(n).toFixed(t) +
            "</span>"
          );
        }
      }

      function setColor(n, type, i = 1, t = 2, e = "", c = 1) {
        // 1: "被动卖",
        // 2: "主动买",
        // 3: "被动买",
        // 4: "主动卖",
        if (i != 1) { 
          if(type==1) return '<span style="color:#00FFFF;flex: 1;text-align: right;">' + dict[n] + e + "</span>" ;
          if(type==2) return '<span style="color:red;flex: 1;text-align: right;">' + dict[n] + e + "</span>" ;
          if(type==3) return '<span style="color:yellow;flex: 1;text-align: right;">' + dict[n] + e + "</span>" ;
          if(type==4) return '<span style="color:#00FF00;flex: 1;text-align: right;">' + dict[n] + e + "</span>" ;
        }

        if(type==1) return '<span style="color:#00FFFF;flex: 1;">' + (parseFloat(n) / c).toFixed(t) + e + "</span>" ;
        if(type==2) return '<span style="color:red;flex: 1;">' + (parseFloat(n) / c).toFixed(t) + e + "</span>" ;
        if(type==3) return '<span style="color:yellow;flex: 1;">' + (parseFloat(n) / c).toFixed(t) + e + "</span>" ;
        if(type==4) return '<span style="color:#00FF00;flex: 1;">' + (parseFloat(n) / c).toFixed(t) + e + "</span>" ;

      }

      function NumberTransform2(n, i, v, m) {
        n = n + "";
        if (i == 0) {
          if (n >= 100000) {
            return n[0] + n[1] + ":" + n[2] + n[3] + ":" + n[4] + n[5];
          } else {
            return "0" + n[0] + ":" + n[1] + n[2] + ":" + n[3] + n[4];
          }
        } else if (i == 1) {
          return "<span style>" + parseFloat(n).toFixed(2) + "</span>";
        } else if (i == 2) {
          if (v == 2) {
            return (
              '<span style="color:#00FF00;font-weight: bold;">' +
              parseFloat(n).toFixed(2) +
              (m == "0" ? "&nbsp;&nbsp;" : m == "2" ? "TT" : "TTT") +
              "</span>"
            );
          } else {
            return (
              '<span style="color:red;font-weight: bold;">' +
              parseFloat(n).toFixed(2) +
              (m == "0" ? "&nbsp;&nbsp;" : m == "2" ? "TT" : "TTT") +
              "</span>"
            );
          }
          // }
        } else if (i == 3) {
          if (v == 2) {
            return (
              '<span style="color:#00FF00;font-weight: bold;">' +
              (ft != 8 ? n : (m / 10000).toFixed(2) + "万") +
              "</span>"
            );
          } else {
            return (
              '<span style="color:red;font-weight: bold;">' +
              (ft != 8 ? n : (m / 10000).toFixed(2) + "万") +
              "</span>"
            );
          }
        }
      }

      function changeStyle() {
        var obj1 = document.getElementById("towrite2");
        obj1.style.left = "0px";
        obj1.style.width = "260px";
        obj1.style.height = "340px";
        obj1.style.fontSize = "12px";
        obj1.style.position = "inherit";
        obj1.style.border = "none";
        obj1.style.margin = "0px";
        obj1.style.padding = "0px";
      }

      function get(z) {
        if (z == 0) {
          buy = !buy;
        } else {
          ft = z;
        }
        if (z == 1) {
          buy = false;
        }
        div = document.getElementById("towrite2");
        div.innerHTML = "";
        // clearInterval(int);
        getSource2();
        // renovate = false;
        // setstop();
        // // int = setInterval(function () {
        // //   getSource2();
        // // }, time);

        document.getElementById("get1").style.color = "#fff";
        document.getElementById("get30").style.color = "#fff";
        document.getElementById("get50").style.color = "#fff";
        document.getElementById("get100").style.color = "#fff";
        document.getElementById("get300").style.color = "#fff";
        document.getElementById("get500").style.color = "#fff";
        // document.getElementById("get8").style.color = "#fff";
        document.getElementById("get0").style.color = "#fff";
        document.getElementById("get" + z).style.color = "aqua";
        document.getElementById("get" + z).style.textDecoration = "underline";
      }
    </script>
  </head>
  <body style="margin: 0">
    <div class="it">
      <div onclick="get(1)" id="get1" style="color: aqua">全部</div>
      <div onclick="get(30)" id="get30">30</div>
      <div onclick="get(50)" id="get50">50</div>
      <div onclick="get(100)" id="get100">100</div>
      <div onclick="get(300)" id="get300">300</div>
      <div onclick="get(500)" id="get500">500</div>
      <!-- <div onclick="get(8)" id="get8">&nbsp;&nbsp;买家</div> -->
      <div onclick="get(0)" id="get0">&nbsp;&nbsp;买家</div>
      <div onclick="setstop()" id="setstop">&nbsp;&nbsp;刷</div>
    </div>
    <div id="towrite2" class="fixedBox" style="margin-bottom: 0"></div>
    <div id="towrite" class="fixedBox" style="display: none"></div>
    <div id="towrite3" style="font-size: 12px">11</div>

    <style type="text/css">
      .it {
        display: flex;
        cursor: pointer;
        margin: 0;
        padding: 0;
        font-size: 10px;
      }
      .it div {
        margin-bottom: 0;
        padding-left: 4px;
      }
      .it div:hover {
        color: aqua;
        text-decoration: underline;
      }

      #towrite {
        padding: 0;
      }
      #towrite2 ul {
        list-style: none;
        margin: 2px 0;
      }
    </style>

    <script>
      let dom = document.querySelector("#towrite2");
      dom.addEventListener("scroll", function (e) {
        if (
          e.target.scrollHeight - e.target.clientHeight >
          e.target.scrollTop
        ) {
          renovate = false;
          document.getElementById("setstop").innerHTML = "&nbsp;&nbsp;刷";
        }
      });
      function setstop() {
        if (renovate) {
          return;
        }
        renovate = true;
        getSource2();
      }
    </script>
  </body>
</html>
